package sketch.specs;

import java.util.List;
import java.util.Map;

import org.eclipse.jdt.core.dom.Comment;
import org.eclipse.jdt.core.dom.MethodDeclaration;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

public class SketchedIdentifierBlockTest extends TestCase {
	
	public static Test suite() {
		
		return new TestSuite(SketchedIdentifierBlockTest.class);
	}
	
	public void testReadIdentifierBlock() {
		System.out.println("Testing testReadIdentifierBlock!");
		String filePath = "./testfiles/sketch/specs/IdBlock.java";;
		SketchedMethodsCreator creator = new SketchedMethodsCreator(filePath);
		List<SketchedMethodDeclaration> methods = creator.createSketchedMethodList();
		Map<Comment, SketchedBlock> sketchedBlocks = creator.getSketchedBlocks();
		System.out.println(sketchedBlocks.size());
		assertTrue(sketchedBlocks.size() == 4);
		//wrapped that with try-catch
		for(SketchedBlock block : sketchedBlocks.values()) {
			assertTrue(block instanceof SketchedIdentifierBlock);
			SketchedIdentifierBlock idBlock = (SketchedIdentifierBlock)block;
			System.out.println("ID: " + idBlock.identifier);
			System.out.println(block);
		}
	}
	
//	public void testExpandIdentifierBlocks() {
//		System.out.println("Testing testExpandIdentifierBlocks!");
//		String filePath = "./tests/sketch/specs/idblock.txt";;
//		SketchedMethodsCreator creator = new SketchedMethodsCreator(filePath);
//		List<SketchedMethodDeclaration> methods = creator.createSketchedMethodList();
//		assertTrue(methods.size() == 1);
//		
//		SketchedMethodDeclaration method = methods.get(0);
//		List<MethodDeclaration> method_decls = method.getMethodsAfterExpansion();
//		assertEquals(2, method_decls.size());
//		
//		for(MethodDeclaration m : method_decls) {
//			System.out.println("-- ");
//			System.out.println(m);
//		}
//	}
}